
********************************************************************************
************************* REPLICATION CODE *************************************
********************************************************************************


/* This file contains replication codes for:
S.Panel, E.Paulis, J.-B.Pilet, S.Rojon and D.Vittori (2023), The lure of 
technocrats: a conjoint experiment on preferences for technocratic ministers in
six European countries, forthcoming, Political Behavior.

*/



********************************************************************************
**************************** MAIN RESULTS **************************************
********************************************************************************

use TechnocratsData


*********** Main estimates (detailed results reported in Appendix D) *******


* Prime minister
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="France" , cluster(ResponseId)
est store PMFr
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Germany" , cluster(ResponseId)
est store PMGer
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Italy" , cluster(ResponseId)
est store PMIt
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Poland" , cluster(ResponseId)
est store PMPol
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Spain" , cluster(ResponseId)
est store PMSp
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="UK" , cluster(ResponseId)
est store PMUK

* Specialized ministries
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="France" , cluster(ResponseId)
est store SMFr
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Germany" , cluster(ResponseId)
est store SMGer
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Italy" , cluster(ResponseId)
est store SMIt
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Poland" , cluster(ResponseId)
est store SMPol
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Spain" , cluster(ResponseId)
est store SMSp
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="UK" , cluster(ResponseId)
est store SMUK


** Fig 1
coefplot (PMFr)(SMFr) || (PMGer) (SMGer) || (PMPol) (SMPol) || (PMUK) (SMUK) || ///
 (PMIt) (SMIt) || (PMSp) (SMSp) ///
 , drop(_cons) xline(0)  bycoefs
 
 
 
 
 ********** Predicted probabilities for selected profiles (by country) *******
 
 
 * France
reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation i.class ///
 i.match if task!="PM" & Country=="France" , /// 
cluster(ResponseId)
margins, at(minage=40 gendernum=1 party=1 class=0 occupation=3 account2=2 expertise=1) at /// 
(minage=40 gendernum=1 party=1 class=0 occupation=2 account2=0 expertise=1) ///
at(minage=40 gendernum=2 party=1 class=1 account2=0 occupation=4 expertise=1) ///
at(minage=65 gendernum=2 party=1 class=1 account2=0 occupation=1 expertise=0) ///
  at(minage=65 gendernum=2 party=2 class=1 occupation=0 account2=1 expertise=0) post
  est store fr
  
 * Germany
  reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation ///
  i.class i.match if task!="PM" & Country=="Germany" , /// 
cluster(ResponseId)
margins, at(minage=40 gendernum=1 party=1 class=0 occupation=3 account2=2 expertise=1) at /// 
(minage=40 gendernum=1 party=1 class=0 occupation=2 account2=0 expertise=1) ///
at(minage=40 gendernum=2 party=1 class=1 account2=0 occupation=4 expertise=1) ///
at(minage=65 gendernum=2 party=1 class=1 account2=0 occupation=1 expertise=0) ///
  at(minage=65 gendernum=2 party=2 class=1 occupation=0 account2=1 expertise=0) post
  est store de
  
 * Italy
 reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation i.class ///
 i.match if task!="PM" & Country=="Italy" , /// 
cluster(ResponseId)
margins, at(minage=40 gendernum=1 party=1 class=0 occupation=3 account2=2 expertise=1) at /// 
(minage=40 gendernum=1 party=1 class=0 occupation=2 account2=0 expertise=1) ///
at(minage=40 gendernum=2 party=1 class=1 account2=0 occupation=4 expertise=1) ///
at(minage=65 gendernum=2 party=1 class=1 account2=0 occupation=1 expertise=0) ///
  at(minage=65 gendernum=2 party=2 class=1 occupation=0 account2=1 expertise=0) post
  est store it
  
* Spain
  reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation ///
  i.class i.match if task!="PM" & Country=="Spain" , /// 
cluster(ResponseId)
margins, at(minage=40 gendernum=1 party=1 class=0 occupation=3 account2=2 expertise=1) at /// 
(minage=40 gendernum=1 party=1 class=0 occupation=2 account2=0 expertise=1) ///
at(minage=40 gendernum=2 party=1 class=1 account2=0 occupation=4 expertise=1) ///
at(minage=65 gendernum=2 party=1 class=1 account2=0 occupation=1 expertise=0) ///
  at(minage=65 gendernum=2 party=2 class=1 occupation=0 account2=1 expertise=0) post
  est store sp
  
 * Poland
  reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation i.class ///
  i.match if task!="PM" & Country=="Poland" , /// 
cluster(ResponseId)
margins, at(minage=40 gendernum=1 party=1 class=0 occupation=3 account2=2 expertise=1) at /// 
(minage=40 gendernum=1 party=1 class=0 occupation=2 account2=0 expertise=1) ///
at(minage=40 gendernum=2 party=1 class=1 account2=0 occupation=4 expertise=1) ///
at(minage=65 gendernum=2 party=1 class=1 account2=0 occupation=1 expertise=0) ///
  at(minage=65 gendernum=2 party=2 class=1 occupation=0 account2=1 expertise=0) post
  est store pl
  
 *UK
   reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation ///
   i.class i.match if task!="PM" & Country=="UK" , /// 
cluster(ResponseId)
margins, at(minage=40 gendernum=1 party=1 class=0 occupation=3 account2=2 expertise=1) at /// 
(minage=40 gendernum=1 party=1 class=0 occupation=2 account2=0 expertise=1) ///
at(minage=40 gendernum=2 party=1 class=1 account2=0 occupation=4 expertise=1) ///
at(minage=65 gendernum=2 party=1 class=1 account2=0 occupation=1 expertise=0) ///
  at(minage=65 gendernum=2 party=2 class=1 occupation=0 account2=1 expertise=0) post
  est store uk
  
 ** Figure 2 
coefplot fr de it pl sp uk, vertical legend(position(0) bplacement(neast)) xlabel ///
 (1 `""Age 40" "Female" "Not a party member" "Working class origins" "Academic" "Responsive to citizens" "Field expert""' ///
 2 `""Age 40" "Female" "Not a party member" "Working class origins" "High-ranking civil servant" "Follow own expertise" "Field expert""' ///
 3 `""Age 40" "Male" "Not a party member" "Upper class origins" "Businessperson" "Follow own expertise" "Field expert""' ///
 4 `""Age 65" "Male" "Not a party member" "Upper class origins" "Minister" "Follow own expertise" "Not a field expert""' ///
 5 `""Age 65" "Male" "Party member" "Upper class origins" "MP" "Responsive to parliament" "Not a field expert""')
 
 
 
 *******************************************************************************
 ********************* DETAILED RESULTS BY MINISTRY ****************************
 ****************************  APPENDIX E **************************************

 * France
 reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Agriculture" & Country=="France" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Education" & Country=="France" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Finance" & Country=="France" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Foreign" & Country=="France" , cluster(ResponseId)

 * Germany
 reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Agriculture" & Country=="Germany" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Education" & Country=="Germany" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Finance" & Country=="Germany" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Foreign" & Country=="Germany" , cluster(ResponseId)

 * Italy
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Agriculture" & Country=="Italy" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Education" & Country=="Italy" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Finance" & Country=="Italy" , cluster(ResponseId)
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Foreign" & Country=="Italy" , cluster(ResponseId)
 
 * Poland
  reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Agriculture" & Country=="Poland" , cluster(ResponseId)
   reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Education" & Country=="Poland" , cluster(ResponseId)
   reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Finance" & Country=="Poland" , cluster(ResponseId)
   reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Foreign" & Country=="Poland" , cluster(ResponseId)
 
 * Spain
   reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Agriculture" & Country=="Spain" , cluster(ResponseId)
    reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Education" & Country=="Spain" , cluster(ResponseId)
    reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Finance" & Country=="Spain" , cluster(ResponseId)
    reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Foreign" & Country=="Spain" , cluster(ResponseId)
 
 * UK
    reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Agriculture" & Country=="UK" , cluster(ResponseId)
    reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Education" & Country=="UK" , cluster(ResponseId)
     reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Finance" & Country=="UK" , cluster(ResponseId)
     reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task=="Foreign" & Country=="UK" , cluster(ResponseId)
 
 
 
 
 
 *******************************************************************************
 ***************************** ROBUSTNESS CHECKS *******************************
 ******************************* APPENDIX F ************************************
 
 
 
* Estimation method: logistic regression (Appendix F1)
 
* Prime minister
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="France" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Germany" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Italy" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Poland" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Spain" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="UK" , cluster(ResponseId)

* Specialized ministries
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="France" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Germany" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Italy" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Poland" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Spain" , cluster(ResponseId)
logit selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="UK" , cluster(ResponseId)


* Exclusing low-quality responses (Appendix F2)

preserve
drop if Q17_A=="Failed for softlaunch respondents"
drop if Q17_A=="Minister of Sport"

* Prime minister
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="UK" , cluster(ResponseId)

* Specialized ministries
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="UK" , cluster(ResponseId)

restore


* Sampling weights (Appendix F3)

 * Prime minister
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="France" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Germany" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Italy" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Poland" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="Spain" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" & Country=="UK" [pweight = ALL_weights]

* Specialized ministries
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="France" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Germany" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Italy" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Poland" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="Spain" [pweight = ALL_weights]
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 i.expert if task!="PM" & Country=="UK" [pweight = ALL_weights]
 
 
* Design effects (1): first profile dummy as a covariate (Appendix F4)

* Variable identifying first profile for each task
recode vignette (1 3 5 7 9=1) (2 4 6 8 10=0), gen (firstprof)

* Prime minister
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof if task=="PM" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof if task=="PM" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof if task=="PM" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof if task=="PM" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof if task=="PM" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof if task=="PM" & Country=="UK" , cluster(ResponseId)

* Agriculture
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Agriculture" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Agriculture" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Agriculture" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Agriculture" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Agriculture" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Agriculture" & Country=="UK" , cluster(ResponseId)

* Education
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Education" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Education" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Education" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Education" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Education" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Education" & Country=="UK" , cluster(ResponseId)

* Finance
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Finance" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Finance" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Finance" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Finance" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Finance" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Finance" & Country=="UK" , cluster(ResponseId)

* Foreign affairs
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Foreign" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Foreign" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Foreign" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Foreign" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Foreign" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof i.expert if task=="Foreign" & Country=="UK" , cluster(ResponseId)

 
* Design effects (2): first profile dummy interacted with the number of identical attributes (Appendix F4)

* variable identifying identical attributes
bys ResponseId task minage: gen sameage=cond(_N==1, 0, _n), after(minage)
replace sameage=1 if sameage==2
bys ResponseId task gendernum: gen samegender=cond(_N==1, 0, _n)
replace samegender=1 if samegender==2
bys ResponseId task expertise: gen sameexp=cond(_N==1, 0, _n)
replace sameexp=1 if sameexp==2
replace sameexp=. if expertise==.
bys ResponseId task account2: gen sameacc=cond(_N==1, 0, _n)
replace sameacc=1 if sameacc==2
bys ResponseId task party: gen samepart=cond(_N==1, 0, _n)
replace samepart=1 if samepart==2
bys ResponseId task occupation: gen sameocc=cond(_N==1, 0, _n)
replace sameocc=1 if sameocc==2
bys ResponseId task class: gen sameclass=cond(_N==1, 0, _n)
replace sameclass=1 if sameclass==2
bys ResponseId task match: gen samematch=cond(_N==1, 0, _n)
replace samematch=1 if samematch==2

gen sametotal=sameage + samegender + sameex + sameacc + samepar + sameocc + sameclass + samematch
egen n_identical=rowtotal (sameage samegender sameex sameacc samepar sameocc sameclass samematch)

* Prime minister
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof##c.n_ident if task=="PM" & Country=="France" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof##c.n_ident i.firstprof if task=="PM" & Country=="Germany" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof##c.n_ident i.firstprof if task=="PM" & Country=="Italy" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof##c.n_ident i.firstprof if task=="PM" & Country=="Poland" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof##c.n_ident i.firstprof if task=="PM" & Country=="Spain" , cluster(ResponseId)
reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.firstprof##c.n_ident i.firstprof if task=="PM" & Country=="UK" , cluster(ResponseId)


* Other ministries 
bys Country: reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.expert i.firstprof##c.n_ident if task=="Agriculture", cluster(ResponseId)
bys Country: reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.expert i.firstprof##c.n_ident if task=="Education", cluster(ResponseId)
bys Country: reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.expert i.firstprof##c.n_ident if task=="Finance", cluster(ResponseId)
bys Country: reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
i.expert i.firstprof##c.n_ident if task=="Foreign", cluster(ResponseId)


* Design effects (3): baseline estimates for first vs. second profile (Appendix F4)

bys Country firstprof: reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="PM" , cluster(ResponseId)
 bys Country firstprof: reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="Agriculture" , cluster(ResponseId)
bys Country firstprof: reg selected i.minage i.gendernum i.account2 i.party i.occupation i.class i.match ///
 if task=="Education" , cluster(ResponseId)
 

* Exclusion of unlikely profiles (Appendix F5)

* Exclude outsiders without field expertise (specialized ministries only)
gen exclude_1=0
replace exclude_1=1 if occupation==2 & expertise==0
replace exclude_1=1 if occupation==3 & expertise==0
replace exclude_1=1 if occupation==4 & expertise==0
reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation ///
 i.class i.match i.countryn if task!="PM" & exclude_1==0 , cluster(ResponseId)
est store exclude
reg selected i.minage i.gendernum i.expertise i.account2 i.party i.occupation ///
 i.class i.match i.countryn if task!="PM" , cluster(ResponseId)
 est store baseline
coefplot (baseline, label(baseline)) (exclude, label(exclude)), ///
drop(_cons 1.countrynum 2.countrynum 3.countrynum 4.countrynum 5.countrynum ///
 6.countrynum)  xline(0) 
 
* Exclude profiles responsive to the parliament but unaffiliated to a party
gen exclude_2=0
replace exclude_2=1 if party==1 & account2==1
reg selected i.minage i.gendernum i.account2 i.party i.occupation ///
 i.class i.match i.countryn if task=="PM" & exclude_2==0 , cluster(ResponseId)
est store exclude_pm
reg selected i.minage i.gendernum i.account2 i.party i.occupation ///
 i.class i.match i.expert i.countryn if task!="PM" & exclude_2==0, cluster(ResponseId)
 est store exclude_othermin
reg selected i.minage i.gendernum i.account2 i.party i.occupation ///
 i.class i.match i.countryn if task=="PM", cluster(ResponseId)
est store baseline_pm
reg selected i.minage i.gendernum i.account2 i.party i.occupation ///
 i.class i.match i.expert i.countryn if task!="PM", cluster(ResponseId)
 est store baseline_othermin
coefplot (baseline_pm) (exclude_pm), bylabel(PM) || (baseline_othermin)  ///
(exclude_othermin), bylabel(othermin) ||, ///
drop(_cons 1.countrynum 2.countrynum 3.countrynum 4.countrynum 5.countrynum ///
 6.countrynum)  xline(0) 
 
 

 *******************************************************************************
 ********************** ADDITIONAL ANALYSES ************************************
 ************************** APPENDIX G	****************************************
 
 
 * Interaction of expertise and policy positions (Table 25, Appendix G1)
 
 reg selected i.minage i.gendernum i.account2 i.party i.occupation ///
 i.class i.match##i.expert i.countryn if task!="PM", cluster(ResponseId)
 
 * Interaction of policy positions and party membership (Table 26, left panel)
 
 *PM
 reg selected i.minage i.gendernum i.account2 i.occupation ///
 i.class i.party##i.match i.countryn if task=="PM", cluster(ResponseId)
 
 * other ministers
reg selected i.minage i.gendernum i.account2 i.occupation i.expert ///
 i.class i.party##i.match i.countryn if task!="PM", cluster(ResponseId)
 
* Interaction of policy positions and occupation (Table 26, right panel)

* Pm
 reg selected i.minage i.gendernum i.account2  i.party ///
 i.class i.occupation##i.match i.countryn if task=="PM", cluster(ResponseId)
 
 * other ministers
  reg selected i.minage i.gendernum i.account2  i.party i.expert ///
 i.class i.occupation##i.match i.countryn if task!="PM", cluster(ResponseId)
 
 
* Attribute effects when the two profiles in a task endorse the same policy position
* (Appendix G2)

* flag tasks with two identical policy positions
bys ResponseId task minpol:  gen sameposition = cond(_N==1,0,_n)
recode sameposition (2=1)

* replicate PM estimates for the two subsamples:
bys Country sameposition: reg selected i.minage i.gendernum i.account2 i.party  ///
 i.occupation i.class i.match if task=="PM", cluster(ResponseId)

* replicate other ministries estimates for the two subsamples:
bys Country sameposition: reg selected i.minage i.gendernum i.account2 i.party  ///
 i.occupation i.class i.match i.expert if task!="PM", cluster(ResponseId)
 
 
* Interaction effects between expertise and other attributes (Appendix G3)

* Interaction of expertise and responsiveness (Table 27)
quietly reg selected i.minage i.gendernum  i.party  i.occupation i.class ///
 i.match i.countryn i.expert##i.account2 if task!="PM", cluster(ResponseId)
 margins i.expertise#i.account2
 
* Interaction of expertise and working background (Table 28)
quietly reg selected i.minage i.gendernum  i.party  i.account2 i.class ///
 i.match i.countryn i.expert##i.occupation if task!="PM", cluster(ResponseId)
 margins i.expertise#i.occupation
 

 * Attribute effects depending on issue attention
 
 * Issue attention dummy (1 if issue deemed "very important", 0 otherwise)
 gen salience = 0
replace salience=. if task==""
replace salience =1 if Q33_IssuePriority_1=="Very important" & task=="Foreign"
replace salience=. if Q33_IssuePriority_1==""
replace salience =1 if Q33_IssuePriority_2=="Very important" & task=="Education"
replace salience=. if Q33_IssuePriority_2==""
replace salience =1 if Q33_IssuePriority_3=="Very important" & task=="Agriculture"
replace salience=. if Q33_IssuePriority_3==""
replace salience =1 if Q33_IssuePriority_4=="Very important" & task=="Finance"
replace salience=. if Q33_IssuePriority_4==""

bys salience: reg selected i.minage i.gendernum  i.party i.occupation i.account2  ///
i.expert i.class i.match i.countryn if task!="PM", cluster(ResponseId)










 
 
 
 
 
 
 
 


